package com.fastwire.carriere.controller.impl;

import com.fastwire.carriere.common.util.DateUtil;
import com.fastwire.carriere.controller.HuronController;
import com.fastwire.carriere.dao.DAOException;
import com.fastwire.carriere.dao.DAOFactory;
import com.fastwire.carriere.dao.SiteDao;
import com.fastwire.carriere.inventory.entity.Site;
import com.fastwire.carriere.nas2.vo.SiteVo;

public class HuronControllerImpl implements HuronController {

	private final SiteDao siteDao = DAOFactory.getInstance().getSiteDao();

	public void createOrUpdateSite(SiteVo siteVo) throws DAOException {

		Site site = siteDao.getSitebyName(siteVo.getSiteName());
		if (site == null) {

			site = new Site();
			site.setName(siteVo.getSiteName());

		}

		site.setAddress(siteVo.getAddress());
		site.setFibreCode(siteVo.getFibreCode());
		site.setPostalCode(siteVo.getPostalCode());
		site.setUpdateby(siteVo.getUpdatedby());
		site.setUpdateDate(DateUtil.getDate());

		siteDao.saveOrUpdate(site);

	}
}
